QuickTime 4 API Documentation

3D Graphics Programming with QuickDraw 3D 1.5.4

Previous | QD3D Book | Overview | Chapter Contents | Next |

Attribute Arrays

An attribute array contains all of the information contained in a single TQ3TriMeshAttribute (described below). It also contains information that identifies the location of this particular attribute array with respect to all of the other attribute arrays contained in the trimesh.

Labels

ASCII
AttributeArray
Binary
atar ( = 0x61746172 )

HEADER AND DATA

An attribute array has a header consisting of five numbers. The first number is type TQ3Int32 and the last four are type TQ3Uns32 .

TQ3Int32
AttributeType field of TQ3TriMeshAttribute
TQ3Uns32
Reserved and currently unused; should always be 0.
TQ3Uns32
Call this field positionOfArray . 0 means this TQ3TriMeshAttribute is an element in the array of TQ3TriMeshAttribute s pointed to by the triangleAttributeTypes field of TQ3TriMeshData . Similarly, 1 means it's an element in the edgeAttributeTypes array, and 2 means it's in vertexAttributeTypes .
TQ3Uns32
Call this field positionInArray . It specifies the element in the array singled out by field 3 above ( positionOfArray ). It's 0-based, so 0 means the first TQ3TriMeshAttribute in the array, 1 the second, etc.
TQ3Uns32
A flag; 0 if the attributeUseArray field of TQ3TriMeshAttribute is NULL , 1 otherwise. If it's 1, the attributeUseArray data follows immediately. It consists of one TQ3Uns8 for each attribute in the attribute array.

The header is followed by the data. For built-in attributes, if the attribute type is anything other than kQ3AttributeTypeSurfaceShader , the data is part of the attribute array's root object, so it immediately follows the header in a continuous stream. The size of the data is determined by the AttributeType field. If the attribute type is kQ3AttributeTypeSurfaceShader , then the texture shaders appear as subobjects, and the attribute array root contains only the header. If the attribute is a custom attribute, then the attributes also appear as subobjects. This is the case even if the data for the custom attribute is simple, such as one float value.

EXAMPLE

The following is an example of a metafile that describes a trimesh with a moderately complex set of attribute arrays. This example represents a complete metafile written by QD3D 1.5.

3DMetafile ( 1 5 Normal tableofcontents0> )
    trimesh2:
    Container (
        TriMesh (
            4 2 3 1 6 1         # numTriangles
                                # numTriangleAttributeTypes
                                # numEdges
                                # numEdgeAttributeTypes
                                # numPoints
                                # numVertexAttributeTypes
            0 3 1
            0 2 3
            2 4 3
            4 5 3
            0 3 0 1
            2 3 1 2
            3 4 2 3
            -20 -20 0 -20 10 0 0 0 0
            0 30 0 20 -20 0 20 10 0
            -20 -20 -1 20 30 1 False )

        AttributeArray (
            6 0 0 0 0
            0.2 0.6 0.8
            1 0 0
            0 1 0.5
            0 0.2 1
        )
        Container (
            AttributeArray ( 11 0 0 1 0
            )
            textureshader3:
            Container (
                TextureShader ( )
                pixmaptexture4:
                PixmapTexture (
                    8 8 36 32           # RGB32 BigEndian BigEndian
                    0x000000FF000000FF0000FF000000FF00
                    0x0000FF000000FF000000FF000000FF00
                    0x01909860000000FF000000FF0000FF00
                    0x0000FF000000FF000000FF000000FF00
                    0x0000FF00047F00000000FF000000FF00
                    0x0000FF000000FF000000FF000000FF00
                    0x0000FF000000FF00000000000000FF00
                    0x0000FF000000FF000000FF000000FF00
                    0x0000FF000000FF000000FF00B7A401E6
                    0x0000FF000000FF000000FF000000FF00
                    0x0000FF000000FF000000FF000000FF00
                    0x000000500000FF000000FF000000FF00
                    0x0000FF000000FF000000FF000000FF00
                    0x0000FF00000000000000FF000000FF00
                    0x0000FF000000FF000000FF000000FF00
                    0x0000FF000000FF0001E856400000FF00
                    0x0000FF000000FF000000FF000000FF00
                    0x0000FF000000FF000000FF0000000000
                )
            )


            textureshader5:
            Container (
                TextureShader ( )
                pixmaptexture6:
                PixmapTexture (
                    8 8 36 32           # RGB32 BigEndian BigEndian
                    0x00FFFF0000FFFF0000FFFF0000FFFF00
                    0x00FFFF0000FFFF0000FF000000FF0000
                    0x0012602000FFFF0000FFFF0000FFFF00
                    0x00FFFF0000FFFF0000FFFF0000FF0000
                    0x00FF000001E857B000FFFF0000FFFF00
                    0x00FFFF0000FFFF0000FFFF0000FFFF00
                    0x00FF000000FF0000AB00001400FFFF00
                    0x00FFFF0000FFFF0000FFFF0000FFFF00
                    0x00FFFF0000FF000000FF000000000030
                    0x00FFFF0000FFFF0000FFFF0000FFFF00
                    0x00FFFF0000FFFF0000FF000000FF0000
                    0x0000000000FFFF0000FFFF0000FFFF00
                    0x00FFFF0000FFFF0000FFFF0000FF0000
                    0x00FF000001E6B75C00FF000000FF0000
                    0x00FF000000FF000000FF000000FF0000
                    0x00FF000000FF00000001000000FF0000
                    0x00FF000000FF000000FF000000FF0000
                    0x00FF000000FF000000FF0000000001E6
                )
            )
            Reference ( 1 )
            Reference ( 2 )
        )
        AttributeArray (
            7 0 1 0 0
            0.3
            0.4
            0.6
        )



        AttributeArray (
            2 0 2 0 0
            0 0
            0 1
            1 0
            1 1
            0 0
            0 1
        )
        attributeset7:
        Container (
            AttributeSet ( )
            AmbientCoefficient ( 0.5 )
            DiffuseColor ( 1 0 0 )
        )
    )
    tableofcontents0:
    TableOfContents (
        tableofcontents1>           # next TOC
        3                           # reference seed
        -1                          # typeSeed
        1                           # tocEntryType
        16                          # tocEntrySize
        2                           # nEntries
        1 textureshader3>
        TextureShader
        2 textureshader5>
        TextureShader
    )

© 1997 Apple Computer, Inc.

Previous | QD3D Book | Overview | Chapter Contents | Next |